local file = require("FileUtils")
local ts = require("ts")
local logs = require("Log")
   require("tsnet")
local PythonNet={}
local tottalpathscard =getSDCardPath().. "/test.png"
local my_path = "";
local my_url = "";
 ts.setHttpsTimeOut(60)
function PythonNet.config(url,path1)
    my_path = path1
    my_url = url
end

function PythonNet.ocr_python_up(c1,c2,c3,c4)
    snapshot(tottalpathscard,c1,c2,c3,c4)
    local b64 = file.readFileB64(tottalpathscard)
    local url1 = my_url .. my_path
    local header_send =  {aaa=123,cd=12}
    local body_send =   {picBase=b64,bbb=222}
    local status,header,c = http.post(url1,{headers=header_send,params=body_send,opts={charset="utf-8"}})
    local c123  = ts.json.decode(c)
    return c123["data"]
end

function PythonNet.ocr_python_whole(url1,c1, c2, c3, c4)
    snapshot(tottalpathscard,c1,c2,c3,c4)
    local b64 = file.readFileB64(tottalpathscard)
    local header_send =  {aaa=123,cd=12}
    local body_send =   {picBase=b64,bbb=222}
    local status,header,c = http.post(url1,{headers=header_send,params=body_send,opts={charset="utf-8"}})
    local c123  = ts.json.decode(c)
    return c123["data"]
end

function PythonNet.ocr_python_whole_end(url1,c1, c2, c3, c4)
    snapshot(tottalpathscard,c1,c2,c3,c4)
    local b64 = file.readFileB64(tottalpathscard)
    local header_send =  {aaa=123,cd=12}
     logs.nLog("base64"..b64)
    local body_send =   {picBase=b64,bbb=222}
    local status,header,c = http.post(my_url..url1,{headers=header_send,params=body_send,opts={charset="utf-8"}})
    local c123  = ts.json.decode(c)
    return c123["data"]
end

function PythonNet.postGetTable(url1,json)
 
  local header_send =  {aaa=123,cd=12}
 
    local  status_resp,header_resp, body_resp  = http.post(my_url..url1,{headers=header_send,params=json,opts={charset="utf-8"}})
    local c123 = ts.json.decode(body_resp)
    return c123
end



function PythonNet.getGetTable(url1,json)

    local header_send =  {aaa=123,cd=12}
    local body_send =   json
    status_resp, header_resp,body_resp = http.get(my_url..url1,{headers=header_send,params=body_send,opts={charset="utf-8"}})
    local c123 = ts.json.decode(body_resp)
    return c123
end

return PythonNet